Xbasic

TOP_PERCENT_RECORDS Function

Syntax

Filter_Expression as C = top_percent_records(percent as n[,filter as c])

Arguments

Filter_Expression

An expression that selects records from a table.

percent

A positive number less than or equal to 100. Numeric

filter

Optional. Default = ".T." (All records). A character filter expression that evaluates to a logical value and selects records from the table. Character

Description

Return the top N percent of records for a given sort order.

Discussion

A special function used only in queries to return the top Percent of records in a table for a given sort order. If the optional filter is supplied, only the records selected by the filter are returned. Note : The term "top" does not imply that record values are examined. "Top" means first, given the current sort order.

See Top, Bottom, Nth Record and Random Record Queries for more information. The following query, which could be attached to a button on a form, returns the top 10% of students in a school.

dim tbl as P
dim inx as P
tbl = table.current()
query.filter = "top_percent_records(10)"
query.order = "grade_point_average"
inx = tbl.query_create()
topparent.resynch()

See Also